package vn.vnvas.xoso;

import java.util.ArrayList;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class myAdapter extends ArrayAdapter<Mien> {
	private Context mContext;
	private ArrayList<Mien> array;

	public myAdapter(Context context, int textViewResourceId,ArrayList<Mien> arrays) {
		super(context, textViewResourceId, arrays);
		// TODO Auto-generated constructor stub

		this.mContext = context;
		this.array = arrays;

	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View studentView = convertView;
		if (studentView == null) {
			studentView = new LayoutItem(mContext);
		}

		// lay tung phan tu mang tuong ung voi vi tri cua adapter
		Mien mien = array.get(position);
		if (mien != null) {
			// lay tung thanh phan cua item listview
			TextView tvName = ((LayoutItem) studentView).mien;
			ImageView imgPicture = ((LayoutItem) studentView).picture;
			TextView loc_id= ((LayoutItem)studentView).loc_id;

			// set gia tri cho tung thanh phan cua item voi tung thuoc tinh cua
			// doi tuong mang
			tvName.setText(mien.mien);
			imgPicture.setImageBitmap(mien.picture);
			loc_id.setText(mien.loc_id);

		}

		return studentView;

	}

}
